<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>财务管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="css/finances/index.css">
	<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all" />
</head>
<body class="childrenBody">
<div class="layui-tab">
	<ul class="layui-tab-title">
		<li class="layui-this">门店核销统计</li>
		<li>门店提现审核</li>
	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show">
			<div class="list">
				<table class="layui-table" id="customerCarList" lay-filter="customerCarList"></table>
			</div>
		</div>
		<div class="layui-tab-item">
			<div class="list1">
				<table class="layui-table" id="customerCar" lay-filter="customerCar"></table>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="plugins/layui/layui.all.js"></script>
<script type="text/javascript" src="js/user/newsList.js"></script>
<script src="js/TimerButton.js"></script>
<script type="text/html" id="barDemo">
	<button data-method="notice" class="layui-btn" lay-event="edit" style="line-height: 25px;height:25px;">审核通过</button>
    <button data-method="notice" class="layui-btn" lay-event="nopass" style="line-height: 25px;height:25px;">审核不通过</button>
	<!--<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="iconfont icon-edit"></i>审核通过</a>-->
</script>
<script type="text/javascript">
    layui.config({
        base: '/js/admin/'
    }).extend({
        ajaxExtention: 'ajaxExtention',//加载自定义扩展，每个业务js都需要加载这个ajax扩展
        $tool: 'tool'
    }).use(['form', 'layer', 'jquery', 'ajaxExtention', '$tool','table'], function () {
        var tableData=[];
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : parent.layer,
            $ = layui.jquery,
            $tool = layui.$tool,
            table =layui.table;
        table.render({
            elem: '#customerCarList'
            ,url: "/enchashment/cardSubsidyList"
            ,cols: [[
                {checkbox: true, fixed: true}
                ,{field:'merchantId', title: '补贴商户Id',width:"5%"}
                ,{field:'verifiName', title: '核销人'}
                ,{field:'createTime', title: '核销时间',templet:function(d){
                    if(d.createTime!=null){
                        return $tool.formatTime(d.createTime);
                    }else{
                        return "---"
                    }
                }}
                ,{field:'verifiPhone', title: '核销手机号'}
                ,{field:'licensePlateNumber', title: '车牌号'}
                ,{field:'activityId', title: '人保卡卷活动ID'}
                ,{field:'cardCode', title: '卡卷编码'}
                ,{field:'cardAmount', title: '卡卷金额'}
                ,{field:'verifiMultiple', title: '核销补贴倍率'}
                ,{field:'verifiAmount', title: '核销补贴金额'}
                ,{field:'amount', title: '总金额'}
            ]]
            ,page: true
//             ,height: 400
        });
        table.render({
            elem: '#customerCar'
            ,url: "/enchashment/applyEnchashmentList"
            ,cols: [[
                {checkbox: true, fixed: true}
                ,{field:'merchantId', title: '补贴商户Id',width:"5%"}
                ,{field:'walletId', title: '钱包Id',width:"4%"}
                ,{field:'orderNumber', title: '订单号',width:"8%"}
                ,{field:'auditName', title: '审核姓名',width:"8%"}
                ,{field:'status', title: '审核状态',width:"8%",templet:function(d){
                        return d.status ==0?"未审核":d.status ==1?"审核通过":"审核未通过"
                    }}
                ,{field:'tradeAccount', title: '交易人账号',width:"10%"}
                ,{field:'enchashmentName', title: '交易姓名'}
                ,{field:'sum', title: '交易金额',width:"8%"}
                ,{field:'residueAmount', title: '剩余金额',width:"8%"}
                ,{fixed: 'right',title: '操作', align:'center', toolbar: '#barDemo'} //这里的toolbar值是模板元素的选择器
            ]]
            ,page: true
//             ,height: 400
        });
        table.on('tool(customerCar)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            console.log(tr.selector);
            var data1 ={
                id:data.id,
                merchantId:data.merchantId,
                status:""
            }
            if(layEvent === 'edit'){ //查看
                data1.status =1;
                layer.confirm('是否确认审核通过？', {
                    btn: ['通过','取消'] //按钮
                }, function(){
                    $.ajax({
                        type : "POST",
                        url: '/enchashment/auditTransfer',
                        data:data1,
                        dataType:'json',
                        async:false,
                        success: function(data){
                            console.log(data);
                            if(data.success){
                                layer.msg("审核通过")
							}else{
                                layer.msg("审核失败")
							}
                        }
                    });

                }, function(){
//                   alert("取消")
                });
            }else if(layEvent === 'nopass'){
                data1.status =-1;
                $.ajax({
                    type : "POST",
                    url: '/enchashment/auditTransfer',
                    data:data1,
                    dataType:'json',
                    async:false,
                    success: function(data){
                        console.log(data.msg);
                        layer.msg(data.msg)
                    }
                });
            }
        });
    })
</script>
</body>
</html>